import reportWebVitals from './reportWebVitals';
import React, { Component } from "react";
import { SampleAppFlag, testHelloWorldMain } from "./sample01_helloworld";
import { RenderFlag, testRenderMain } from "./sample02_render";
import { RenderRestructureFlag, testNewRenderMain } from "./sample02_render_restructure";
import { jsxMain } from "./sample03_jsx";
import { componentMain } from "./sample04_component";
import { stateMain } from "./sample05_state";
import { propsMain } from "./sample06_props";

/**
 * 用于存储静态常量
 */
class AppFlag extends React.Component {
    static FLAG_HELLO_WORLD = 0
    static FLAG_RENDER = 1
    static FLAG_RENDER_RESTRUCTURE = 2
    static FLAG_JSX = 3
    static FLAG_COMPONENT = 4
    static FLAG_STATE = 5
    static FLAG_PROPS = 6
}

/**
 * 
 * @param {标识} flag 选择运行哪个程序 
 */
function main(flag) {
    console.log("run main flag = " + flag);
    switch (flag) {
        case AppFlag.FLAG_HELLO_WORLD:
            // 基础功能测试
            testHelloWorldMain(SampleAppFlag.FLAG_SAMPLE_APP);
            break;
        case AppFlag.FLAG_RENDER:
            // 测试渲染
            testRenderMain(RenderFlag.FLAG_CLOCKRENDER);
            break;
        case AppFlag.FLAG_RENDER_RESTRUCTURE:
            // 测试新的渲染-重构之后的代码
            testNewRenderMain(RenderRestructureFlag.FLAG_NEW_RENDER);
            break
        case AppFlag.FLAG_JSX:
            jsxMain();
            break
        case AppFlag.FLAG_COMPONENT:
            componentMain();
            break;
        case AppFlag.FLAG_STATE:
            stateMain();
            break;
        case AppFlag.FLAG_PROPS:
            propsMain();
            break;

    }
    reportWebVitals();
}

// 导出和使用可以参考这个文章：
// https://blog.csdn.net/naipeng/article/details/76944548?utm_source=blogxgwz1
export { AppFlag, main } 